package com.csaba.swing.model;

import java.util.Comparator;

import com.csaba.connector.model.Amount;

public class AmountComparator implements Comparator<Amount>
{

	@Override
	public int compare( final Amount amount1, final Amount amount2 )
	{
		if ( amount1.getCurrency().equals(amount2.getCurrency()) )
		{
			if ( amount1.getAmount() == amount2.getAmount() )
				return 0;
			else
				return amount1.getAmount() < amount2.getAmount() ? -1 : 1;
		}
		return amount1.getCurrency().getSymbol().compareTo(amount2.getCurrency().getSymbol());
	}

}
